/**
 * Created by songj on 2015/12/11.
 */
define(['angular',
    'framework/msg/GillionMsgModule',
    'framework/dataGrid/DataGridModule',
    'framework/pagination/GillionPaginationModule',
    'framework/datasource/DataSourceModule',
    'framework/dropdown/GillionDropdownModule',
    'framework/date/DateModule',
    'angular-underscore'
], function (angular) {
    var module = angular.module('MockController',
        ['GillionMsgModule', 'DataGridModule', 'GillionPaginationModule',
            'DataSourceModule', 'DateModule', 'GillionDropdownModule'])
        .controller('MockController', ['$scope', 'GillionMsgService', '$dataSourceManager', '$timeout', 'Arrays', "$location",'Resource','GillionMsg','$compile','$http',
                function ($scope, GillionMsgService, $dataSourceManager, $timeout, Arrays, $location,Resource) {
                    $scope.unitCaseMock = GillionMsgService.getInputData();
                    $scope.search = {
                        unitCaseMock:  $scope.unitCaseMock
                    };
                    var unitCaseMocks = Resource("/grule-manager/unitcases/mocks/:id", {
                        id: "@id"
                    });
                    $scope.submit=function(){
                        var unitCaseMock = $scope.unitCaseMock;
                        if(unitCaseMock.id==undefined||unitCaseMock.id==null) {
                            unitCaseMocks.create(unitCaseMock, function () {
                                GillionMsgService.close();
                            })
                        }else{
                            unitCaseMocks.update(unitCaseMock, function () {
                                GillionMsgService.close();
                            })
                        }
                    }
                    $scope.cancel = function(){
                        GillionMsgService.close();
                    }


                }
            ]
        );

    module.config(['$locationProvider', function($locationProvider) {
        $locationProvider.html5Mode(true);
    }]);
    return module;
});
